import request from '@/router/axios';

export const addReportConfig = (row) => {
  return request({
    url: '/api/mes-admin/customreport/submit',
    method: 'post',
    data: row
  });
};

export const updateReportConfig = (row) => {
  return request({
    url: '/api/mes-admin/customreport/submit',
    method: 'post',
    data: row
  });
};

export const getReportConfig = (params) => {
  return request({
    url: '/api/mes-admin/customreport/page',
    method: 'get',
    params: {
      ...params
    }
  });
};

export const deleteReportConfig = (row) => {
  return request({
    url: '/api/mes-admin/customreport/remove',
    method: 'post',
    data: row
  });
};

export const viewReportConfig = (row) => {
  return request({
    url: '/api/mes-admin/customreport/detail',
    method: 'get',
    params: { ...row }
  });
};

export const getDataSourceName = (row) => {
  return request({
    url: '/api/blade-system/datasource/detail',
    method: 'get',
    params: { ...row }
  });
};

export const getReportData = (id, params) => {
  return request({
    url: `/api/mes-admin/customreport/reportData/get/id?id=${id}`,
    method: 'POST',
    data: params
  });
};

export const exportReportData = (id, params) => {
  return request({
    url: `/api/mes-admin/customreport/reportData/export/id?id=${id}`,
    method: 'post',
    responseType: 'blob',
    data: params
  });
};
